<%-- 
    Document   : listAssessmentForm
    Created on : Jan 10, 2012, 4:34:05 PM
    Author     : Priyanka
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>


<script>
    $(function() {
        $( "#addAssessment").button({icons: {primary:'ui-icon-circle-plus'}});
        $( "#addAssessment" ).click(function() {
            $('#addAssessmentContainer').html('<img src="<s:url value="/img/loading.gif"/>" style="padding:10px;" border="0"/>');
            
            $.get("<s:url value="/assessment/add_%{selectedModuleCode}"/>", function(data) {
                $('#addAssessmentContainer').hide().html(data).show('fast');
            });
            
        });
    });
</script>




<table>
    <tr>
        <td>
            <button id="addAssessment">&nbsp;&nbsp;Add assessment option</button>
        </td>
    </tr>
</table>


<div id="addAssessmentContainer">
</div>

<br/><br/>

<table width="100%" border="1">  
    <tr>
        <th>ID</th>
        <th>Title</th>
        <th>Description</th>
        <th>Maximum Mark</th>
        <th>Range</th>
        <th>Type</th>
        <th>Actions</th>

    </tr>
    <s:iterator var="item" value="list">
        <tr>
            <td><s:property value="assessmentId"/></td>
            <td><s:property value="title"/></td>
            <td><s:property value="description"/></td>
            <td><s:property value="maximumMark"/></td>
            <td><s:property value="fromRange"/> - <s:property value="toRange"/></td>
            <td><s:property value="type"/></td>
            <td>
                <img src="<s:url value="/img/icons/view.png"/>" alt="View assessment items" onclick="viewAssessment('<s:property value="assessmentId"/>')" style="cursor:pointer"/>
                <img src="<s:url value="/img/icons/add.png"/>" alt="Add assessment items" onclick="addAssessmentItem('<s:property value="assessmentId"/>')" style="cursor:pointer"/>
                <img src="<s:url value="/img/icons/delete.png"/>" alt="Delete" onclick="deleteAssessment('<s:property value="assessmentId"/>')" style="cursor:pointer"/>

            </td>
        </tr>
        <tr>
            <td colspan="7">
                <div id="<s:property value="assessmentId"/>">

                </div>
            </td>
        </tr>
    </s:iterator>
</table> 




<script type="text/javascript">
    
    function deleteAssessment(id) {
        if (!confirm('Do you really want to delete?'))
            return;
        $.post('<s:url value="/assessment/delete_%{selectedModuleCode}"/>',{ idAssessment:id}, function(){
            $('#tabs').tabs( "load" ,1);
        })
    }
    
    function viewAssessment(id) {
        $.post('<s:url value="/assessment/viewItems_%{selectedModuleCode}"/>',{ idAssessment:id}, function(data){
            $('#'+id).hide().html(data).show('fast');
        })
    }
    
    function addAssessmentItem(id) {
        $.post('<s:url value="/assessment/addItems_%{selectedModuleCode}"/>',{ idAssessment:id}, function(data){
            $('#'+id).hide().html(data).show('fast');
        })
    }

</script>